a tool for shared writing and social publishing
1import { makeRouter } from "../lib";
2import { push } from "./push";
3import { createClient } from "@supabase/supabase-js";
4import { Database } from "supabase/database.types";
5import { pull } from "./pull";
6import { getFactsFromHomeLeaflets } from "./getFactsFromHomeLeaflets";
7import { Vercel } from "@vercel/sdk";
8import {
9 get_domain_status,
10 get_leaflet_subdomain_status,
11} from "./domain_routes";
12import { get_leaflet_data } from "./get_leaflet_data";
13import { get_publication_data } from "./get_publication_data";
14import { search_publication_names } from "./search_publication_names";
15import { search_publication_documents } from "./search_publication_documents";
16import { get_profile_data } from "./get_profile_data";
17
18let supabase = createClient<Database>(
19 process.env.NEXT_PUBLIC_SUPABASE_API_URL as string,
20 process.env.SUPABASE_SERVICE_ROLE_KEY as string,
21);
22
23const VERCEL_TOKEN = process.env.VERCEL_TOKEN;
24const vercel = new Vercel({
25 bearerToken: VERCEL_TOKEN,
26});
27const Env = {
28 supabase,
29 vercel,
30};
31export type Env = typeof Env;
32export type Routes = typeof Routes;
33let Routes = [
34 push,
35 pull,
36 getFactsFromHomeLeaflets,
37 get_domain_status,
38 get_leaflet_subdomain_status,
39 get_leaflet_data,
40 get_publication_data,
41 search_publication_names,
42 search_publication_documents,
43 get_profile_data,
44];
45export async function POST(
46 req: Request,
47 { params }: { params: Promise<{ command: string }> },
48) {
49 let p = await params;
50 let router = makeRouter(Routes);
51 return router(p.command, req, Env);
52}